/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cn.ekuma.epos.ical.repository;

import cn.ekuma.epos.datalogic.I_DataLogicERP;
import cn.ekuma.epos.datalogic.I_DataLogicSales;
import cn.ekuma.epos.ical.IEventStore;
import cn.ekuma.epos.ical.event.OrderEvent;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.query.QBFCompareEnum;
import com.openbravo.bean.erp.viewbean.FindOrdersInfo;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrator
 */
public class OrderEventStore implements IEventStore{
    Object[] filter;
    I_DataLogicERP m_dlDales;

    public OrderEventStore(I_DataLogicERP m_dlDales,Object[] filter) {
        this.filter = filter;
        this.m_dlDales = m_dlDales;
    }

    @Override
    public List getEventInstancesForDate(Date start, Date end) {
        filter[6] =  QBFCompareEnum.COMP_GREATEROREQUALS;
        filter[7] = start;
        filter[8] = QBFCompareEnum.COMP_LESS;
        filter[9] = end;
        List<FindOrdersInfo> findOrderInfo=null;
        List<OrderEvent> eventList=new ArrayList();
        try {
            findOrderInfo=m_dlDales.listByFilter(FindOrdersInfo.class,filter);
        } catch (BasicException ex) {
            Logger.getLogger(OrderEventStore.class.getName()).log(Level.SEVERE, null, ex);
        }
        if(findOrderInfo!=null){
            for(FindOrdersInfo order:findOrderInfo)
                eventList.add(new OrderEvent(order));
        }
        return eventList;
    }
}
